package com.link.base.task;

import com.link.base.core.basic.config.xxljob.BaseLinkJobHandler;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.stereotype.Component;

/**
 * 工作流测试
 * 
 * @author huanglongjian
 * @date 2019/07/09 20:52
 */
@JobHandler(value = "crmJobHandler")
@Component
public class TaskDemo extends BaseLinkJobHandler {

    @Override
    public ReturnT<String> execute(String params) throws Exception {
        // XxlJobLogger 打印的日志会体现在调度中心的执行日志中
        XxlJobLogger.log("XXL-JOB, Start.");
        // 调用父的方法设置登录信息
        super.setLogin(params);

        try {
            // 执行自己的业务代码
            int len = 5;
            for (int i = 0; i < len; i++) {
                XxlJobLogger.log("测试:" + i);
            }
        } catch (Exception e) {
            XxlJobLogger.log(e.getMessage());
            return ReturnT.FAIL;
        }
        // 返回成功
        return ReturnT.SUCCESS;
    }

}
